package com.mdp.workflow.bus.candidate.strategy;

import cn.hutool.core.lang.Assert;
import com.mdp.core.utils.StrUtils;
import com.mdp.workflow.bus.candidate.TaskCandidateStrategy;
import com.mdp.workflow.client.service.WfSysUserService;
import org.flowable.engine.delegate.DelegateExecution;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.Set;

/**
 * 岗位 {@link TaskCandidateStrategy} 实现类
 *
 * @author kyle
 */
@Component
public class PostStrategy implements TaskCandidateStrategy {

    @Autowired
    WfSysUserService wfSysUserService;

    @Override
    public com.mdp.workflow.comm.dict.CandidateStrategy getStrategy() {
        return com.mdp.workflow.comm.dict.CandidateStrategy.POST;
    }

    @Override
    public void validateParam(String param) {

        Assert.notNull(param,"岗位编号不能为空，多个以逗号分隔");
    }

    @Override
    public Set<String> calculateUsers(DelegateExecution execution, String param) {
        return wfSysUserService.selectUseridsByPostIds(Arrays.asList(param.split(",")));
    }

}